home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / WASTE 1.2 Distribution / WASTE 1.2 / WASTEIntf.h < prev    next >
Encoding:
Text File  |  1996-06-25  |  58.8 KB  |  1,371 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    WASTEIntf.h
  3.  *
  4.  *    WASTE PROJECT
  5.  *  Internal (private) interface, version 1.2
  6.  *
  7.  *  Copyright (c) 1993-1996 Marco Piovanelli
  8.  *    All Rights Reserved
  9.  *
  10.  *  C port by Dan Crevier
  11.  *
  12.  */
  13.  
  14. //    Toolbox #includes
  15.  
  16. #ifndef __CONDITIONALMACROS__
  17. #include <ConditionalMacros.h>
  18. #endif
  19.  
  20. #ifndef UNIVERSAL_INTERFACES_VERSION
  21. #error "You need Universal Headers version 2.1 or newer to compile WASTE"
  22. #endif
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27.  
  28. #ifndef __MIXEDMODE__
  29. #include <MixedMode.h>
  30. #endif
  31.  
  32. #ifndef __CODEFRAGMENTS__
  33. #include <CodeFragments.h>
  34. #endif
  35.  
  36. #ifndef __ERRORS__
  37. #include <Errors.h>
  38. #endif
  39.  
  40. #ifndef __GESTALT__
  41. #include <Gestalt.h>
  42. #endif
  43.  
  44. #ifndef __MEMORY__
  45. #include <Memory.h>
  46. #endif
  47.  
  48. #ifndef __FONTS__
  49. #include <Fonts.h>
  50. #endif
  51.  
  52. #ifndef __QUICKDRAWTEXT__
  53. #include <QuickdrawText.h>
  54. #endif
  55.  
  56. #ifndef __QUICKDRAW__
  57. #include <Quickdraw.h>
  58. #endif
  59.  
  60. #ifndef __QDOFFSCREEN__
  61. #include <QDOffscreen.h>
  62. #endif
  63.  
  64. #ifndef __PALETTES__
  65. #include <Palettes.h>
  66. #endif
  67.  
  68. #ifndef __TEXTEDIT__
  69. #include <TextEdit.h>
  70. #endif
  71.  
  72. #ifndef __SCRAP__
  73. #include <Scrap.h>
  74. #endif
  75.  
  76. #ifndef __SCRIPT__
  77. #include <Script.h>
  78. #endif
  79.  
  80. #ifndef __TOOLUTILS__
  81. #include <ToolUtils.h>
  82. #endif
  83.  
  84. #ifndef __TEXTUTILS__
  85. #include <TextUtils.h>
  86. #endif
  87.  
  88. #ifndef __LOWMEM__
  89. #include <LowMem.h>
  90. #endif
  91.  
  92. #ifndef __APPLEEVENTS__
  93. #include <AppleEvents.h>
  94. #endif
  95.  
  96. #ifndef __AEREGISTRY__
  97. #include <AERegistry.h>
  98. #endif
  99.  
  100. #ifndef __DRAG__
  101. #include <Drag.h>
  102. #endif
  103.  
  104. #ifndef __TEXTSERVICES__
  105. #include <TextServices.h>
  106. #endif
  107.  
  108. //    ANSI #includes
  109.  
  110. #ifndef _LIMITS
  111. #include <limits.h>
  112. #endif
  113.  
  114. //    other #includes
  115.  
  116. #ifndef __LONGCOORDINATES__
  117. #ifndef _LongCoords_
  118. #include "LongCoords.h"
  119. #endif
  120. #endif
  121.  
  122. // MPW needs topLeft and botRight defined here
  123. #ifndef topLeft
  124. #define topLeft(r)              (((Point *) &(r))[0])
  125. #endif
  126.  
  127. #ifndef botRight
  128. #define botRight(r)             (((Point *) &(r))[1])
  129. #endif
  130.  
  131. // pascal-like macros for testing, setting, clearing and inverting bits
  132. #define BTST( FLAGS, BIT )    ((FLAGS) &   (1L << (BIT)))
  133. #define BSET( FLAGS, BIT )  ((FLAGS) |=  (1L << (BIT)))
  134. #define BCLR( FLAGS, BIT )  ((FLAGS) &= ~(1L << (BIT)))
  135. #define BCHG( FLAGS, BIT )  ((FLAGS) ^=  (1L << (BIT)))
  136.  
  137. // pascal-like macros for shifting bits
  138. #define BSL( A, B )            (((SInt32) (A)) << (B))
  139. #define BSR( A, B )            (((SInt32) (A)) >> (B))
  140.  
  141. // macros used in conjunction with the styleRunPosition parameter
  142. #define IS_FIRST_RUN(RUN)    ((RUN) <= leftStyleRun)
  143. #define IS_LAST_RUN(RUN)    (! ((RUN) & 0x01))
  144.  
  145. // other macros
  146. #define ABS(A)                 ((A) > 0 ? (A) : -(A))
  147. #define BLOCK_CLR(X)        _WEBlockClr(&(X), sizeof(X));
  148.  
  149. // define WASTE_VERSION is standard NumVersion format
  150.  
  151. #define WASTE_VERSION        0x00128000    /* 1.2f */
  152.  
  153. // set WASTE_DEBUG to 1 to perform various consistency checks;
  154. // errors will be reported with DebugStr()
  155. // WARNING: when WASTE_DEBUG is set, WEIdle() calls can be extremely time-consuming
  156. #ifndef WASTE_DEBUG
  157. #define WASTE_DEBUG                0
  158. #endif
  159.  
  160. // set WASTE_OBJECTS to 0 if you don't need embedded objects
  161. #ifndef WASTE_OBJECTS
  162. #define    WASTE_OBJECTS            1
  163. #endif
  164.  
  165. // set WASTE_USE_UPPS to 0 if you don't need UPPs
  166. #ifndef WASTE_USE_UPPS
  167. #define WASTE_USE_UPPS            GENERATINGCFM
  168. #endif
  169.  
  170. // set WASTE_REDRAW_SPEED to 1 to use Mark Alldritt's optimizations of _WERedraw
  171. #ifndef WASTE_REDRAW_SPEED
  172. #define WASTE_REDRAW_SPEED        0
  173. #endif
  174.  
  175. // set WASTE_NO_SYNCH to 1 if you don't want WASTE to synchronize keyboard and fonts
  176. #ifndef WASTE_NO_SYNCH
  177. #define WASTE_NO_SYNCH            0
  178. #endif
  179.  
  180. // set WASTE_NO_RO_CARET to 1 to hide the caret in read-only mode
  181. #ifndef WASTE_NO_RO_CARET
  182. #define WASTE_NO_RO_CARET        1
  183. #endif
  184.  
  185. // set WASTE_IC_SUPPORT to 1 to use Dan Crevier's
  186. // support of URL cmd-clicking through Internet Config
  187. #ifndef WASTE_IC_SUPPORT
  188. #define WASTE_IC_SUPPORT        1
  189. #endif
  190.  
  191. // If WASTE_OBJECTS_ARE_GLYPHS is set to 0 (default), WEGetOffset returns kObjectEdge in
  192. // the edge parameter when thePoint is in the middle half of an object: as a result,
  193. // clicking in the middle of an object immediately _selects_ the object, so that a second
  194. // click immediately following triggers the 'clik' callback (this can be handy to make
  195. // sound objects play when they are double-clicked, for example).
  196.  
  197. // If WASTE_OBJECTS_ARE_GLYPHS is set to 1, WEGetOffset treats embedded objects
  198. // like ordinary glyphs and never returns kObjectEdge in the edge parameter:
  199. // as a result, clicking in the middle of an object always positions the caret either
  200. // to the left or to the right of the object.
  201.  
  202. #ifndef WASTE_OBJECTS_ARE_GLYPHS
  203. #define WASTE_OBJECTS_ARE_GLYPHS    0
  204. #endif
  205.  
  206. // set WASTE_RESOLVE_FONT_DESIGNATORS to false if you don't want WASTE to
  207. // map font designators (the special IDs 0 and 1 that identify the system
  208. // and application fonts, respectively) to the actual font IDs.
  209.  
  210. #ifndef WASTE_RESOLVE_FONT_DESIGNATORS
  211. #define WASTE_RESOLVE_FONT_DESIGNATORS    1
  212. #endif
  213.  
  214. // set WASTE_WECALTEXT_DOES_REDRAW to 1 if you want WECalText()
  215. // to automatically redraw all the text (as in WASTE 1.1 final)
  216.  
  217. #ifndef WASTE_WECALTEXT_DOES_REDRAW
  218. #define WASTE_WECALTEXT_DOES_REDRAW        0
  219. #endif
  220.  
  221. // set WASTE_KURTHS_OPTION_ARROWS to 0 to use the old
  222. // implementation of option + left/right arrow combinations, which is
  223. // less conformant to Apple's HIGs than the current implementation,
  224. // due to Stefan Kurth
  225.  
  226. #ifndef WASTE_KURTHS_OPTION_ARROWS
  227. #define WASTE_KURTHS_OPTION_ARROWS        1
  228. #endif
  229.  
  230. // macros for debugging
  231.  
  232. #if WASTE_DEBUG
  233. #define WEASSERT(CONDITION, WARNING)    { if (!(CONDITION)) DebugStr(WARNING); }
  234. #else
  235. #define WEASSERT(CONDITION, WARNING)
  236. #endif
  237.  
  238. // determine if inline functions are supported
  239.  
  240. #if defined(__cplusplus) || defined(__MWERKS__)
  241. #define INLINE inline
  242. #else
  243. #define INLINE static
  244. #endif
  245.  
  246. // result codes
  247. enum {
  248.     weCantUndoErr                =    -10015,    // undo buffer is clear (= errAECantUndo)
  249.     weEmptySelectionErr            =    -10013,    // selection range is empty (= errAENoUserSelection)
  250.     weUnknownObjectTypeErr        =    -9478,    // specified object type is not registered
  251.     weObjectNotFoundErr            =    -9477,    // no object found at specified offset
  252.     weReadOnlyErr                =    -9476,    // instance is read-only
  253.     weMonoStyledErr                =    -9475,    // instance is mono-styled
  254.     weNotHandledErr                =    -1708,  // please use default handling (= errAEEventNotHandled)
  255.     weUndefinedSelectorErr        =    -50,    // unknown selector
  256.     weNoDragErr                 =     128        // can be returned internally by _WEDrag
  257. };
  258.  
  259. // values for WEInstallObjectHandler handlerSelector parameter
  260. enum {
  261.     weNewHandler         =     'new ',
  262.     weDisposeHandler     =     'free',
  263.     weDrawHandler         =     'draw',
  264.     weClickHandler         =     'clik',
  265.     weStreamHandler        =    'strm'
  266. };
  267.  
  268. // action kinds
  269. enum {
  270.     weAKNone            =    0,        // null action
  271.     weAKUnspecified        =    1,        // action of unspecified nature
  272.     weAKTyping            =    2,        // some text has been typed in
  273.     weAKCut                =    3,        // the selection range has been cut
  274.     weAKPaste            =    4,        // something has been pasted
  275.     weAKClear            =    5,        // the selection range has been deleted
  276.     weAKDrag            =    6,        // drag and drop operation
  277.     weAKSetStyle        =    7        // some style has been applied to a text range
  278. };
  279.  
  280. // action flags
  281. enum {
  282.     weAFIsRedo            =    0x0001,    // action saves edit state prior to a WEUndo call
  283.     weAFDontSaveText    =    0x0002, // don't save text
  284.     weAFDontSaveStyles    =    0x0004,    // don't save styles
  285.     weAFDontSaveSoup    =    0x0008    // don't save soup
  286. };
  287.  
  288. // destination kinds for streaming objects
  289. enum {
  290.     weToScrap            =    0,
  291.     weToDrag            =    1,
  292.     weToSoup            =    2
  293. };
  294.  
  295. // alignment styles
  296. enum {
  297.     weFlushLeft         =    -2,        // flush left
  298.     weFlushRight        =    -1,        // flush right
  299.     weFlushDefault        =     0,        // flush according to system direction
  300.     weCenter            =     1,        // centered
  301.     weJustify            =     2        // fully justified
  302. };
  303.  
  304. // values for the edge parameter
  305. enum {
  306.     kLeadingEdge         =     -1,        // point is on the leading edge of a glyph
  307.     kTrailingEdge         =      0,        // point is on the trailing edge of a glyph
  308.     kObjectEdge         =      2        // point is inside an embedded object
  309. };
  310.  
  311. // control character codes
  312. enum {
  313.     kObjectMarker         =    0x01,
  314.     kBackspace             =    0x08,
  315.     kTab                 =    0x09,
  316.     kEOL                 =    0x0D,
  317.     kArrowLeft             =    0x1C,
  318.     kArrowRight         =    0x1D,
  319.     kArrowUp             =    0x1E,
  320.     kArrowDown             =    0x1F,
  321.     kSpace                 =      0x20,
  322.     kForwardDelete         =    0x7F
  323. };
  324.  
  325. // bit equates for the tsFlags field of the WETextStyle record
  326. enum {
  327.     tsTSMHilite         =    4,        // set if style run is part of active input area
  328.     tsTSMSelected         =    5,        // set for selected raw/converted text
  329.     tsTSMConverted         =    6,        // set for converted text, clear for raw text
  330.     tsRightToLeft         =    7        // set for right-to-left runs
  331. };
  332.  
  333. // bit equates for the mode parameter in WESetStyle and WEContinuousStyle
  334. enum {
  335.     kModeFont             =    0,        // change font
  336.     kModeFace             =    1,        // change Quickdraw styles
  337.     kModeSize             =    2,        // change point size
  338.     kModeColor             =    3,        // change color
  339.     kModeAddSize         =    4,        // add tsSize to existing size
  340.     kModeToggleFace     =    5,        // toggle continuous styles rather than setting them
  341.     kModeReplaceFace     =    6,        // tsFace replaces existing styles outright
  342.     kModePreserveScript =    7,        // apply font to runs of same script only
  343.     kModeExtractSubscript = 8,        // apply font to eligible subruns of different script
  344.     kModeFaceMask         =     9,        // change Quickdraw styles; use mask
  345.     kModeObject         =     14,        // change tsObject field
  346.     kModeFlags             =     15        // change tsFlags field
  347. };
  348.  
  349. // values for the mode parameter in WESetStyle and WEContinuousStyle
  350. enum {
  351.     weDoFont                =    1 << kModeFont,
  352.     weDoFace                =    1 << kModeFace,
  353.     weDoSize                =    1 << kModeSize,
  354.     weDoColor                =    1 << kModeColor,
  355.     weDoAll                    =    weDoFont + weDoFace + weDoSize + weDoColor,
  356.     weDoAddSize                =    1 << kModeAddSize,
  357.     weDoToggleFace            =    1 << kModeToggleFace,
  358.     weDoReplaceFace            =    1 << kModeReplaceFace,
  359.     weDoPreserveScript        =    1 << kModePreserveScript,
  360.     weDoSmartFont            =    weDoFont + weDoPreserveScript,
  361.     weDoExtractSubscript    =    1 << kModeExtractSubscript,
  362.     weDoFaceMask            =    1 << kModeFaceMask,
  363.     weDoObject                =    1 << kModeObject,
  364.     weDoFlags                =    1 << kModeFlags
  365. };
  366.  
  367. // values for WEFeatureFlag action parameter
  368. enum {
  369.     weBitSet             =     1,        // enables the specified feature
  370.     weBitClear             =     0,        // disables the specified feature
  371.     weBitTest             =    -1,        // returns the current setting of the specified feature
  372.     weBitToggle         =    -2        // toggles the specified feature
  373. };
  374.  
  375. // bit equates for the flags field in the WE record
  376. enum {
  377.     weFHasColorQD             =    31,        // Color Quickdraw is available
  378.     weFHasDragManager         =    30,        // the Drag Manager is available
  379.     weFHasTextServices        =    29,        // the Text Services Manager is available
  380.     weFNonRoman                =    28,        // at least one non-Roman script is enabled
  381.     weFDoubleByte            =    27,        // a double-byte script is enabled
  382.     weFBidirectional        =    26,        // a bidirectional script is enabled
  383.     weFUseDualCaret            =    25,        // use dual caret at direction boundaries
  384.     weFCaretVisible            =    24,        // the caret is currently visible
  385.     weFMouseTracking        =    23,        // set internally during mouse tracking
  386.     weFAnchorIsEnd            =    22,        // anchor offset is selEnd
  387.     weFUseNullStyle            =    21,        // a null style is associated with the empty selection
  388.     weFActive                =    20,        // we're active
  389.     weFHilited                =    19,        // true if text pane is highlighted (for Drag & Drop)
  390.     weFCanAcceptDrag        =    18,        // the drag in the text pane can be accepted
  391.     weFDragCaretVisible        =    17,        // drag caret is currently visible
  392.     weFDestRectChanged        =    16,        // set if scroll callback needs to be called
  393.     weFHasTranslucentDrags    =    15        // SetDragImage is available
  394. };
  395.  
  396. // bit equates for the features field in the WE record
  397. enum {
  398.     weFInhibitColor        =    31,        // draw in black & white only; ignore color
  399.     weFMonoStyled        =    13,        // disallow style changes
  400.     weFInhibitRedraw    =    12,        // don't redraw text
  401.     weFDrawOffscreen    =    11,        // draw text offscreen for smoother visual results
  402.     weFUseTempMem        =    10,        // use temporary memory for main data structures
  403.     weFInhibitRecal        =     9,        // don't recalculate line breaks and don't redraw text
  404.     weFDragAndDrop        =     8,        // support drag and drop
  405.     weFIntCutAndPaste    =     7,        // intelligent cut & paste
  406.     weFUndoSupport        =     6,        // support undo/redo
  407.     weFReadOnly            =     5,        // disallow editing
  408.     weFOutlineHilite    =     2,        // frame selection range when text pane is inactive
  409.     weFAutoScroll        =     0        // automatically scroll text when cursor is outside pane
  410. };
  411.  
  412. // scrap types
  413. enum {
  414.     kTypeText            =    'TEXT',
  415.     kTypeStyles         =    'styl',
  416.     kTypeSoup             =    'SOUP'
  417. };
  418.  
  419. // selectors for WEGetInfo/WESetInfo
  420. enum {
  421.     weCharByteHook            =    'cbyt',
  422.     weCharTypeHook            =    'ctyp',
  423.     weCharToPixelHook        =    'c2p ',
  424.     weClickLoop                =    'clik',
  425.     weCurrentDrag            =    'drag',
  426.     weDrawTextHook            =    'draw',
  427.     weHiliteDropAreaHook    =    'hidr',
  428.     weLineArray                =    'line',
  429.     weLineBreakHook            =    'lbrk',
  430.     wePixelToCharHook        =    'p2c ',
  431.     wePort                    =    'port',
  432.     weRefCon                =    'refc',
  433.     weRunArray                =    'runa',
  434.     weScrollProc            =    'scrl',
  435.     weStyleTable            =    'styl',
  436.     weText                    =    'text',
  437.     weTranslateDragHook        =    'xdrg',
  438.     weTSMDocumentID            =    'tsmd',
  439.     weTSMPostUpdate            =    'post',
  440.     weTSMPreUpdate            =    'pre ',
  441.     weURLHint                =    'urlh',
  442.     weWordBreakHook            =    'wbrk'
  443. };
  444.  
  445. // possible values returned by WEIntelligentPaste
  446. enum {
  447.     weDontAddSpaces            =     0,
  448.     weAddSpaceOnLeftSide    =    -1,
  449.     weAddSpaceOnRightSide    =     1
  450. };
  451.  
  452. // values for WEAllocate allocFlags parameter
  453. enum {
  454.     kAllocClear            =    0x00000001,    // clear handle after allocation
  455.     kAllocTemp            =    0x00000002    // use temporary memory if available
  456. };
  457.  
  458. // other miscellaneous constants
  459. enum {
  460.     kCaretWidth = 1,            // width of the caret, in pixels
  461.     kMinFontSize = 1,            // minimum valid font size
  462.     kMaxFontSize = SHRT_MAX,    // maximum valid font size
  463.     kInvalidOffset = -1,         // used to flag an invalid or nonexistent offset
  464.     kUnknownObjectType = -1,    // returned by _WELookupObjectType for unknown flavors
  465.     kNullDrag = 0,                // null or nonexistent drag reference
  466.     kTextMargin = 3,            // width of border area surrounding the text (in pixels)
  467.     kMaxScrollDelta = 30,        // maximum scroll amount used by standard click loop
  468.     kAutoScrollDelay = 10,        // delay before auto-scroll starts (in ticks)
  469.     kDefaultObjectHeight = 32,    // default height for new objects
  470.     kDefaultObjectWidth = 32    // default width for new objects
  471. };
  472.  
  473. #if defined(powerc) || defined (__powerc)
  474. #pragma options align=mac68k
  475. #endif
  476.  
  477. typedef UInt16 WEStyleMode;
  478. typedef SInt8 WEAlignment;
  479. typedef SInt8 WEEdge;
  480. typedef SInt16 WEActionKind;
  481. typedef UInt16 WEActionFlags;
  482.  
  483. // forward declarations
  484.  
  485. typedef struct WERec *WEPtr, **WEHandle;
  486. typedef struct WEObjectDesc *WEObjectDescPtr, **WEObjectDescHandle;
  487.  
  488. typedef struct WETextStyle {
  489.     SInt16 tsFont;                    // font family number
  490.     Style tsFace;                    // set of Quickdraw styles
  491.     UInt8 tsFlags;                    // flags (FOR INTERNAL USE ONLY)
  492.     SInt16 tsSize;                    // font size, in integer points
  493.     RGBColor tsColor;                // absolute red-green-blue color
  494. #if WASTE_OBJECTS
  495.     WEObjectDescHandle tsObject;    // embedded object reference
  496. #endif
  497. } WETextStyle, *WETextStylePtr, **WETextStyleHandle;
  498.  
  499. typedef struct WERunAttributes {
  500.     SInt16 runHeight;            // style run height (ascent + descent + leading)
  501.     SInt16 runAscent;            // font ascent
  502.     WETextStyle runStyle;        // text style
  503. } WERunAttributes, *WERunAttributesPtr, **WERunAttributesHandle;
  504.  
  505. typedef struct WERunInfo {
  506.     SInt32 runStart;            // byte offset to first character of this style run
  507.     SInt32 runEnd;                // byte offset to first character of next style run
  508.     WERunAttributes runAttrs;    // run attributes
  509. } WERunInfo, *WERunInfoPtr, **WERunInfoHandle;
  510.  
  511. typedef struct QDEnvironment {
  512.     GrafPtr envPort;
  513.     PenState envPen;
  514.     WETextStyle envStyle;
  515.     SInt16 envMode;
  516. } QDEnvironment;
  517.  
  518. typedef struct RunArrayElement {
  519.     SInt32 runStart;            // offset to first character in style run
  520.     SInt32 styleIndex;            // index into style table
  521. } RunArrayElement, *RunArrayElementPtr, **RunArrayElementHandle;
  522.  
  523. typedef RunArrayElementPtr RunArrayPtr;
  524. typedef RunArrayElementHandle RunArrayHandle;
  525.  
  526. typedef struct TERunAttributes {
  527.     SInt16 runHeight;
  528.     SInt16 runAscent;
  529.     TextStyle runTEStyle;
  530. } TERunAttributes, *TERunAttributesPtr;
  531.  
  532. typedef struct TEStyleScrapElement {
  533.     SInt32 scrpStartChar;
  534.     TERunAttributes scrpTEAttrs;
  535. } TEStyleScrapElement, *TEStyleScrapElementPtr;
  536.  
  537. typedef struct TEStyleScrap {
  538.     SInt16 scrpNStyles;
  539.     TEStyleScrapElement scrpStyleTab[ kVariableLengthArray ];
  540. } TEStyleScrap, *TEStyleScrapPtr, **TEStyleScrapHandle;
  541.  
  542. typedef struct StyleTableElement {
  543.     SInt32 refCount;            // reference count
  544.     WERunAttributes info;        // style information
  545. } StyleTableElement, *StyleTableElementPtr, **StyleTableElementHandle;
  546.  
  547. typedef StyleTableElementPtr StyleTablePtr;
  548. typedef StyleTableElementHandle StyleTableHandle;
  549.  
  550. typedef struct LineRec {
  551.     SInt32 lineStart;            // byte offset to first character in line
  552.     SInt32 lineOrigin;            // pixel offset from destRect.top
  553.     SInt16 lineAscent;            // maximum font ascent for this line
  554.     SInt16 lineSlop;            // extra pixels needed to fill up the line
  555.     Fixed lineJustAmount;        // normalized slop value, used for justification
  556. } LineRec, *LinePtr, **LineHandle;
  557.  
  558. typedef LinePtr LineArrayPtr;
  559. typedef LineHandle LineArrayHandle;
  560.  
  561. typedef struct WEAction {
  562.     WEHandle hOwner;            // handle to associated WE instance
  563.     struct WEAction **hNext;    // used to keep a linked list of actions
  564.     Handle hText;                // handle to saved text
  565.     Handle hStyles;                // handle to saved styles
  566.     Handle hSoup;                // handle to saved soup
  567.     SInt32 delRangeStart;        // start of range to delete
  568.     SInt32 delRangeLength;        // length of range to delete
  569.     SInt32 insRangeLength;        // lenfth of range to insert
  570.     SInt32 hiliteStart;            // start of range to hilite
  571.     SInt32 hiliteEnd;            // end of range to hilite
  572.     WEActionKind actionKind;    // identifies event that caused this action to be pushed
  573.     WEActionFlags actionFlags;    // miscellaneous flags
  574. } WEAction, *WEActionPtr, **WEActionHandle;
  575.  
  576. // A WESoup record is a static description of an object embedded in the text.
  577. // The 'SOUP' data type is just a collection of WESoup records, each followed
  578. // by the corresponding object data.
  579. // This data type complements the standard TEXT/styl pair.
  580.  
  581. typedef struct WESoup {
  582.     SInt32 soupOffset;            // insertion offset for this object
  583.     FlavorType soupType;        // 4-letter tag identifying object type
  584.     SInt32 soupReserved1;        // reserved for future use; set to zero
  585.     Size soupDataSize;            // size of object data following this record
  586.     Point soupSize;                // object height and width, in pixels
  587.     SInt32 soupReserved2;        // reserved for future use; set to zero
  588. } WESoup, *WESoupPtr, **WESoupHandle;
  589.  
  590. // callback prototypes
  591.  
  592. typedef pascal Boolean (*WEClickLoopProcPtr)(WEHandle hWE);
  593. typedef pascal void (*WEScrollProcPtr)(WEHandle hWE);
  594. typedef pascal void (*WETSMPreUpdateProcPtr)(WEHandle hWE);
  595. typedef pascal void (*WETSMPostUpdateProcPtr)(WEHandle hWE,
  596.         SInt32 fixLength, SInt32 inputAreaStart, SInt32 inputAreaEnd,
  597.         SInt32 pinRangeStart, SInt32 pinRangeEnd);
  598. typedef pascal OSErr (*WETranslateDragProcPtr)(DragReference drag,
  599.         ItemReference dragItem, FlavorType requestedType, Handle putDataHere,
  600.         SInt32 dropOffset, WEHandle hWE);
  601. typedef pascal OSErr (*WEHiliteDropAreaProcPtr)(DragReference drag,
  602.         Boolean hiliteFlag, WEHandle hWE);
  603. typedef pascal void (*WEDrawTextProcPtr)(Ptr pText, SInt32 textLength, Fixed slop,
  604.         JustStyleCode styleRunPosition, WEHandle hWE);
  605. typedef pascal SInt32 (*WEPixelToCharProcPtr)(Ptr pText, SInt32 textLength, Fixed slop,
  606.         Fixed *pixelWidth, WEEdge *edge, JustStyleCode styleRunPosition, Fixed hPos, WEHandle hWE);
  607. typedef pascal SInt16 (*WECharToPixelProcPtr)(Ptr pText, SInt32 textLength, Fixed slop,
  608.         SInt32 offset, SInt16 direction, JustStyleCode styleRunPosition, SInt32 hPos, WEHandle hWE);
  609. typedef pascal StyledLineBreakCode (*WELineBreakProcPtr)(Ptr pText, SInt32 textLength,
  610.         SInt32 textStart, SInt32 textEnd, Fixed *textWidth, SInt32 *textOffset, WEHandle hWE);
  611. typedef pascal void (*WEWordBreakProcPtr)(Ptr pText, SInt16 textLength, SInt16 offset,
  612.         WEEdge edge, OffsetTable breakOffsets, ScriptCode script, WEHandle hWE);
  613. typedef pascal SInt16 (*WECharByteProcPtr)(Ptr pText, SInt16 textOffset, ScriptCode script,
  614.         WEHandle hWE);
  615. typedef pascal SInt16 (*WECharTypeProcPtr)(Ptr pText, SInt16 textOffset, ScriptCode script, WEHandle hWE);
  616.  
  617. typedef pascal OSErr (*WENewObjectProcPtr)(Point *defaultObjectSize,
  618.         WEObjectDescHandle hObjectDesc);
  619. typedef pascal OSErr (*WEDisposeObjectProcPtr)(WEObjectDescHandle hObjectDesc);
  620. typedef pascal OSErr (*WEDrawObjectProcPtr)(const Rect *destRect,
  621.         WEObjectDescHandle hObjectDesc);
  622. typedef pascal Boolean (*WEClickObjectProcPtr)(Point hitPt, EventModifiers modifiers, UInt32 clickTime,
  623.         WEObjectDescHandle hObjectDesc);
  624. typedef pascal OSErr (*WEStreamObjectProcPtr)(SInt16 destKind, FlavorType *theType, Handle putDataHere, WEObjectDescHandle hObjectDesc);
  625.  
  626.  
  627. // UPP proc info
  628.  
  629. enum {
  630.     uppWEClickLoopProcInfo = kPascalStackBased
  631.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  632.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  633. };
  634. enum {
  635.     uppWEScrollProcInfo = kPascalStackBased
  636.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  637. };
  638. enum {
  639.     uppWETSMPreUpdateProcInfo = kPascalStackBased
  640.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  641. };
  642. enum {
  643.     uppWETSMPostUpdateProcInfo = kPascalStackBased
  644.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  645.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(SInt32 /*fixLength*/)))
  646.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(SInt32 /*inputAreaStart*/)))
  647.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(SInt32 /*inputAreaEnd*/)))
  648.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(SInt32 /*pinRangeStart*/)))
  649.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(SInt32 /*pinRangeEnd*/)))
  650. };
  651. enum {
  652.     uppWETranslateDragProcInfo = kPascalStackBased
  653.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  654.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(DragReference /*drag*/)))
  655.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(ItemReference /*dragItem*/)))
  656.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(FlavorType /*requestedType*/)))
  657.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Handle /*putDataHere*/)))
  658.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(SInt32 /*dropOffset*/)))
  659.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  660. };
  661. enum {
  662.     uppWEHiliteDropAreaProcInfo = kPascalStackBased
  663.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  664.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(DragReference /*drag*/)))
  665.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(Boolean /*hiliteFlag*/)))
  666.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  667. };
  668. enum {
  669.     uppWEDrawTextProcInfo = kPascalStackBased
  670.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  671.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(SInt32 /*textLength*/)))
  672.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  673.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  674.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  675. };
  676. enum {
  677.     uppWEPixelToCharProcInfo = kPascalStackBased
  678.         | RESULT_SIZE(SIZE_CODE(sizeof(SInt32)))
  679.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  680.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(SInt32 /*textLength*/)))
  681.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  682.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Fixed * /*pixelWidth*/)))
  683.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(WEEdge * /*edge*/)))
  684.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  685.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(Fixed /*hPos*/)))
  686.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  687. };
  688. enum {
  689.     uppWECharToPixelProcInfo = kPascalStackBased
  690.         | RESULT_SIZE(SIZE_CODE(sizeof(SInt16)))
  691.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  692.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(SInt32 /*textLength*/)))
  693.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  694.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(SInt32 /*offset*/)))
  695.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(SInt16 /*direction*/)))
  696.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  697.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(SInt32 /*hPos*/)))
  698.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  699. };
  700. enum {
  701.     uppWELineBreakProcInfo = kPascalStackBased
  702.         | RESULT_SIZE(SIZE_CODE(sizeof(StyledLineBreakCode )))
  703.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  704.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(SInt32 /*textLength*/)))
  705.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(SInt32 /*textStart*/)))
  706.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(SInt32 /*textEnd*/)))
  707.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(Fixed * /*textWidth*/)))
  708.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(SInt32 * /*textOffset*/)))
  709.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  710. };
  711. enum {
  712.     uppWEWordBreakProcInfo = kPascalStackBased
  713.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  714.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(SInt16 /*textLength*/)))
  715.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(SInt16 /*offset*/)))
  716.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEEdge /*edge*/)))
  717.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(OffsetTable * /*breakOffsets*/)))
  718.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(ScriptCode /*script*/)))
  719.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  720. };
  721. enum {
  722.     uppWECharByteProcInfo = kPascalStackBased
  723.         | RESULT_SIZE(SIZE_CODE(sizeof(SInt16 )))
  724.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  725.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(SInt16 /*textOffset*/)))
  726.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode /*script*/)))
  727.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  728. };
  729. enum {
  730.     uppWECharTypeProcInfo = kPascalStackBased
  731.         | RESULT_SIZE(SIZE_CODE(sizeof(SInt16 )))
  732.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  733.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(SInt16 /*textOffset*/)))
  734.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode /*script*/)))
  735.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEHandle /*hWE*/)))
  736. };
  737.  
  738.  
  739. enum {
  740.     uppWENewObjectProcInfo = kPascalStackBased
  741.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  742.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point * /*defaultObjectSize*/)))
  743.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectDescHandle /*hObjectDesc*/)))
  744. };
  745. enum {
  746.     uppWEDisposeObjectProcInfo = kPascalStackBased
  747.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  748.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEObjectDescHandle /*hObjectDesc*/)))
  749. };
  750. enum {
  751.     uppWEDrawObjectProcInfo = kPascalStackBased
  752.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  753.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(const Rect * /*destRect*/)))
  754.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectDescHandle /*hObjectDesc*/)))
  755. };
  756. enum {
  757.     uppWEClickObjectProcInfo = kPascalStackBased
  758.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  759.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point /*hitPt*/)))
  760.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(SInt16 /*modifiers*/)))
  761.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(UInt32 /*clickTime*/)))
  762.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEObjectDescHandle /*hObjectDesc*/)))
  763. };
  764. enum {
  765.     uppWEStreamObjectProcInfo = kPascalStackBased
  766.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  767.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SInt16 /*destKind*/)))
  768.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FlavorType * /*theType*/)))
  769.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Handle /*putDataHere*/)))
  770.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(WEObjectDescHandle /*hObjectDesc*/)))
  771. };
  772.  
  773.  
  774. /*    UPPs, New≈Proc macros & Call≈Proc macros */
  775.  
  776. /*
  777.     NOTE:
  778.     For compatibility with the Pascal version, Call≈Proc macros take the form:
  779.  
  780.         CallFooProc(..., userRoutine)
  781.  
  782.     instead of:
  783.  
  784.         CallFooProc(userRoutine, ...)
  785.  
  786. */
  787.  
  788. #if WASTE_USE_UPPS
  789.  
  790. typedef UniversalProcPtr WEClickLoopUPP;
  791. typedef UniversalProcPtr WEScrollUPP;
  792. typedef UniversalProcPtr WETSMPreUpdateUPP;
  793. typedef UniversalProcPtr WETSMPostUpdateUPP;
  794. typedef UniversalProcPtr WETranslateDragUPP;
  795. typedef UniversalProcPtr WEHiliteDropAreaUPP;
  796. typedef UniversalProcPtr WEDrawTextUPP;
  797. typedef UniversalProcPtr WEPixelToCharUPP;
  798. typedef UniversalProcPtr WECharToPixelUPP;
  799. typedef UniversalProcPtr WELineBreakUPP;
  800. typedef UniversalProcPtr WEWordBreakUPP;
  801. typedef UniversalProcPtr WECharByteUPP;
  802. typedef UniversalProcPtr WECharTypeUPP;
  803. typedef UniversalProcPtr WENewObjectUPP;
  804. typedef UniversalProcPtr WEDisposeObjectUPP;
  805. typedef UniversalProcPtr WEDrawObjectUPP;
  806. typedef UniversalProcPtr WEClickObjectUPP;
  807. typedef UniversalProcPtr WEStreamObjectUPP;
  808.  
  809. #define NewWEClickLoopProc(userRoutine) \
  810.     (WEClickLoopUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickLoopProcInfo, GetCurrentArchitecture())
  811. #define NewWEScrollProc(userRoutine) \
  812.     (WEScrollUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEScrollProcInfo, GetCurrentArchitecture())
  813. #define NewWETSMPreUpdateProc(userRoutine) \
  814.     (WETSMPreUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPreUpdateProcInfo, GetCurrentArchitecture())
  815. #define NewWETSMPostUpdateProc(userRoutine) \
  816.     (WETSMPostUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPostUpdateProcInfo, GetCurrentArchitecture())
  817. #define NewWETranslateDragProc(userRoutine) \
  818.     (WETranslateDragUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETranslateDragProcInfo, GetCurrentArchitecture())
  819. #define NewWEHiliteDropAreaProc(userRoutine) \
  820.     (WEHiliteDropAreaUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEHiliteDropAreaProcInfo, GetCurrentArchitecture())
  821. #define NewWEDrawTextProc(userRoutine) \
  822.     (WEDrawTextUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawTextProcInfo, GetCurrentArchitecture())
  823. #define NewWEPixelToCharProc(userRoutine) \
  824.     (WEPixelToCharUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEPixelToCharProcInfo, GetCurrentArchitecture())
  825. #define NewWECharToPixelProc(userRoutine) \
  826.     (WECharToPixelUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharToPixelProcInfo, GetCurrentArchitecture())
  827. #define NewWELineBreakProc(userRoutine) \
  828.     (WELineBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWELineBreakProcInfo, GetCurrentArchitecture())
  829. #define NewWEWordBreakProc(userRoutine) \
  830.     (WEWordBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEWordBreakProcInfo, GetCurrentArchitecture())
  831. #define NewWECharByteProc(userRoutine) \
  832.     (WECharByteUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharByteProcInfo, GetCurrentArchitecture())
  833. #define NewWECharTypeProc(userRoutine) \
  834.     (WECharTypeUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharTypeProcInfo, GetCurrentArchitecture())
  835. #define NewWENewObjectProc(userRoutine) \
  836.     (WENewObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWENewObjectProcInfo, GetCurrentArchitecture())
  837. #define NewWEDisposeObjectProc(userRoutine) \
  838.     (WEDisposeObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDisposeObjectProcInfo, GetCurrentArchitecture())
  839. #define NewWEDrawObjectProc(userRoutine) \
  840.     (WEDrawObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawObjectProcInfo, GetCurrentArchitecture())
  841. #define NewWEClickObjectProc(userRoutine) \
  842.     (WEClickObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickObjectProcInfo, GetCurrentArchitecture())
  843. #define NewWEStreamObjectProc(userRoutine) \
  844.     (WEStreamObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEStreamObjectProcInfo, GetCurrentArchitecture())
  845.  
  846. #define CallWEClickLoopProc(hWE, userRoutine) \
  847.     CallUniversalProc((userRoutine), uppWEClickLoopProcInfo, (hWE))
  848. #define CallWEScrollProc(hWE, userRoutine) \
  849.     CallUniversalProc((userRoutine), uppWEScrollProcInfo, (hWE))
  850. #define CallWETSMPreUpdateProc(hWE, userRoutine) \
  851.     CallUniversalProc((userRoutine), uppWETSMPreUpdateProcInfo, (hWE))
  852. #define CallWETSMPostUpdateProc(hWE, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  853.     CallUniversalProc((userRoutine), uppWETSMPostUpdateProcInfo, (hWE), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  854. #define CallWETranslateDragProc(drag, dragItem, requestedType, putDataHere, dropOffset, hWE, userRoutine) \
  855.     CallUniversalProc((userRoutine), uppWETranslateDragProcInfo, (drag), (dragItem), (requestedType), (putDataHere), (dropOffset), (hWE))
  856. #define CallWEHiliteDropAreaProc(drag, hiliteFlag, hWE, userRoutine) \
  857.     CallUniversalProc((userRoutine), uppWEHiliteDropAreaProcInfo, (drag), (hiliteFlag), (hWE))
  858. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, hWE, userRoutine) \
  859.     CallUniversalProc((userRoutine), uppWEDrawTextProcInfo, (pText), (textLength), (slop), (styleRunPosition), (hWE))
  860. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, hWE, userRoutine) \
  861.     CallUniversalProc((userRoutine), uppWEPixelToCharProcInfo, (pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (hWE))
  862. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, hWE, userRoutine) \
  863.     CallUniversalProc((userRoutine), uppWECharToPixelProcInfo, (pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (hWE))
  864. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, hWE, userRoutine) \
  865.     CallUniversalProc((userRoutine), uppWELineBreakProcInfo, (pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (hWE))
  866. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, hWE, userRoutine) \
  867.     CallUniversalProc((userRoutine), uppWEWordBreakProcInfo, (pText), (textLength), (offset), (edge), (breakOffsets), (script), (hWE))
  868. #define CallWECharByteProc(pText, textOffset, script, hWE, userRoutine) \
  869.     CallUniversalProc((userRoutine), uppWECharByteProcInfo, (pText), (textOffset), (script), (hWE))
  870. #define CallWECharTypeProc(pText, textOffset, script, hWE, userRoutine) \
  871.     CallUniversalProc((userRoutine), uppWECharTypeProcInfo, (pText), (textOffset), (script), (hWE))
  872. #define CallWENewObjectProc(defaultObjectSize, hObjectDesc, userRoutine) \
  873.     CallUniversalProc((userRoutine), uppWENewObjectProcInfo, (defaultObjectSize), (hObjectDesc))
  874. #define CallWEDisposeObjectProc(hObjectDesc, userRoutine) \
  875.     CallUniversalProc((userRoutine), uppWEDisposeObjectProcInfo, (hObjectDesc))
  876. #define CallWEDrawObjectProc(destRect, hObjectDesc, userRoutine) \
  877.     CallUniversalProc((userRoutine), uppWEDrawObjectProcInfo, (destRect), (hObjectDesc))
  878. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, hObjectDesc, userRoutine) \
  879.     CallUniversalProc((userRoutine), uppWEClickObjectProcInfo, (hitPt), (modifiers), (clickTime), (hObjectDesc))
  880. #define CallWEStreamObjectProc(destKind, theType, putDataHere, hObjectDesc, userRoutine) \
  881.     CallUniversalProc((userRoutine), uppWEStreamObjectProcInfo, (destKind), (theType), (putDataHere), (hObjectDesc))
  882.  
  883. #else
  884.  
  885. typedef WEClickLoopProcPtr WEClickLoopUPP;
  886. typedef WEScrollProcPtr WEScrollUPP;
  887. typedef WETSMPreUpdateProcPtr WETSMPreUpdateUPP;
  888. typedef WETSMPostUpdateProcPtr WETSMPostUpdateUPP;
  889. typedef WETranslateDragProcPtr WETranslateDragUPP;
  890. typedef WEHiliteDropAreaProcPtr WEHiliteDropAreaUPP;
  891. typedef WEDrawTextProcPtr WEDrawTextUPP;
  892. typedef WEPixelToCharProcPtr WEPixelToCharUPP;
  893. typedef WECharToPixelProcPtr WECharToPixelUPP;
  894. typedef WELineBreakProcPtr WELineBreakUPP;
  895. typedef WEWordBreakProcPtr WEWordBreakUPP;
  896. typedef WECharByteProcPtr WECharByteUPP;
  897. typedef WECharTypeProcPtr WECharTypeUPP;
  898. typedef WENewObjectProcPtr WENewObjectUPP;
  899. typedef WEDisposeObjectProcPtr WEDisposeObjectUPP;
  900. typedef WEDrawObjectProcPtr WEDrawObjectUPP;
  901. typedef WEClickObjectProcPtr WEClickObjectUPP;
  902. typedef WEStreamObjectProcPtr WEStreamObjectUPP;
  903.  
  904. #define NewWEClickLoopProc(userRoutine) ((WEClickLoopUPP) (userRoutine))
  905. #define NewWEScrollProc(userRoutine) ((WEScrollUPP) (userRoutine))
  906. #define NewWETSMPreUpdateProc(userRoutine) ((WETSMPreUpdateUPP) (userRoutine))
  907. #define NewWETSMPostUpdateProc(userRoutine) ((WETSMPostUpdateUPP) (userRoutine))
  908. #define NewWETranslateDragProc(userRoutine) ((WETranslateDragUPP) (userRoutine))
  909. #define NewWEHiliteDropAreaProc(userRoutine) ((WEHiliteDropAreaUPP) (userRoutine))
  910. #define NewWEDrawTextProc(userRoutine) ((WEDrawTextUPP) (userRoutine))
  911. #define NewWEPixelToCharProc(userRoutine) ((WEPixelToCharUPP) (userRoutine))
  912. #define NewWECharToPixelProc(userRoutine) ((WECharToPixelUPP) (userRoutine))
  913. #define NewWELineBreakProc(userRoutine) ((WELineBreakUPP) (userRoutine))
  914. #define NewWEWordBreakProc(userRoutine) ((WEWordBreakUPP) (userRoutine))
  915. #define NewWECharByteProc(userRoutine) ((WECharByteUPP) (userRoutine))
  916. #define NewWECharTypeProc(userRoutine) ((WECharTypeUPP) (userRoutine))
  917. #define NewWENewObjectProc(userRoutine) ((WENewObjectUPP) (userRoutine))
  918. #define NewWEDisposeObjectProc(userRoutine) ((WEDisposeObjectUPP) (userRoutine))
  919. #define NewWEDrawObjectProc(userRoutine) ((WEDrawObjectUPP) (userRoutine))
  920. #define NewWEClickObjectProc(userRoutine) ((WEClickObjectUPP) (userRoutine))
  921. #define NewWEStreamObjectProc(userRoutine) ((WEStreamObjectUPP) (userRoutine))
  922.  
  923. #define CallWEClickLoopProc(hWE, userRoutine) \
  924.     (*(userRoutine))((hWE))
  925. #define CallWEScrollProc(hWE, userRoutine) \
  926.     (*(userRoutine))((hWE))
  927. #define CallWETSMPreUpdateProc(hWE, userRoutine) \
  928.     (*(userRoutine))((hWE))
  929. #define CallWETSMPostUpdateProc(hWE, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  930.     (*(userRoutine))((hWE), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  931. #define CallWETranslateDragProc(drag, dragItem, requestedType, putDataHere, dropOffset, hWE, userRoutine) \
  932.     (*(userRoutine))((drag), (dragItem), (requestedType), (putDataHere), (dropOffset), (hWE))
  933. #define CallWEHiliteDropAreaProc(drag, hiliteFlag, hWE, userRoutine) \
  934.     (*(userRoutine))((drag), (hiliteFlag), (hWE))
  935. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, hWE, userRoutine) \
  936.     (*(userRoutine))((pText), (textLength), (slop), (styleRunPosition), (hWE))
  937. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, hWE, userRoutine) \
  938.     (*(userRoutine))((pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (hWE))
  939. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, hWE, userRoutine) \
  940.     (*(userRoutine))((pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (hWE))
  941. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, hWE, userRoutine) \
  942.     (*(userRoutine))((pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (hWE))
  943. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, hWE, userRoutine) \
  944.     (*(userRoutine))((pText), (textLength), (offset), (edge), (breakOffsets), (script), (hWE))
  945. #define CallWECharByteProc(pText, textOffset, script, hWE, userRoutine) \
  946.     (*(userRoutine))((pText), (textOffset), (script), (hWE))
  947. #define CallWECharTypeProc(pText, textOffset, script, hWE, userRoutine) \
  948.     (*(userRoutine))((pText), (textOffset), (script), (hWE))
  949. #define CallWENewObjectProc(defaultObjectSize, hObjectDesc, userRoutine) \
  950.     (*(userRoutine))((defaultObjectSize), (hObjectDesc))
  951. #define CallWEDisposeObjectProc(hObjectDesc, userRoutine) \
  952.     (*(userRoutine))((hObjectDesc))
  953. #define CallWEDrawObjectProc(destRect, hObjectDesc, userRoutine) \
  954.     (*(userRoutine))((destRect), (hObjectDesc))
  955. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, hObjectDesc, userRoutine) \
  956.     (*(userRoutine))((hitPt), (modifiers), (clickTime), (hObjectDesc))
  957. #define CallWEStreamObjectProc(destKind, theType, putDataHere, hObjectDesc, userRoutine) \
  958.     (*(userRoutine))((destKind), (theType), (putDataHere), (hObjectDesc))
  959.  
  960. #endif
  961.  
  962. typedef Boolean (*SegmentLoopProcPtr)
  963.                 (LinePtr pLine,
  964.                  const WERunAttributes *pAttrs,
  965.                  Ptr pSegment,
  966.                  SInt32 segmentStart,
  967.                  SInt32 segmentLength,
  968.                  JustStyleCode styleRunPosition,
  969.                  WEHandle hWE,
  970.                  void *callbackData);
  971.  
  972. typedef FourCharCode WESelector;
  973.  
  974. typedef struct WEFieldDescriptor {
  975.     SInt16 fOffset;
  976.     SInt16 fLength;
  977. } WEFieldDescriptor;
  978.  
  979. typedef struct WELookupTable {
  980.     WESelector selector;
  981.     WEFieldDescriptor desc;
  982. } WELookupTable;
  983.  
  984. typedef struct WEOHTableElement {
  985.     FlavorType objectType;
  986.     WENewObjectUPP newHandler;
  987.     WEDisposeObjectUPP freeHandler;
  988.     WEDrawObjectUPP drawHandler;
  989.     WEClickObjectUPP clickHandler;
  990.     WEStreamObjectUPP streamHandler;
  991.     SInt32 refCon;
  992. } WEOHTableElement, *WEOHTablePtr, **WEOHTableHandle;
  993.  
  994. typedef struct WEObjectDesc {
  995.     FlavorType objectType;                // 4-letter tag identifying object type
  996.     Handle objectDataHandle;            // handle to object data
  997.     Point objectSize;                    // object height and width, in pixels
  998.     WEOHTableHandle objectTable;        // handle to object handler table
  999.     SInt32 objectIndex;                    // index into object handler table
  1000.     WEHandle objectOwner;                // handle to owner WE instance
  1001.     SInt32 objectRefCon;                // free for use by object handlers
  1002. } WEObjectDesc;
  1003.  
  1004. typedef struct    WERec {
  1005.     GrafPtr port;                            // graphics port text is drawn into
  1006.     Handle hText;                            // handle to the text
  1007.     LineArrayHandle hLines;                    // handle to the line array
  1008.     StyleTableHandle hStyles;                // handle to the style table
  1009.     RunArrayHandle hRuns;                    // handle to the style run array
  1010.     SInt32 textLength;                        // length of text
  1011.     SInt32 nLines;                            // number of lines
  1012.     SInt32 nStyles;                            // number of unique styles in the style table
  1013.     SInt32 nRuns;                            // number of style runs
  1014.     LongRect viewRect;                        // view rectangle, all drawing is clipped to this
  1015.     LongRect destRect;                        // destination rectangle
  1016.     SInt32 selStart;                        // start of selection range
  1017.     SInt32 selEnd;                            // end of selection range
  1018.     UInt32 flags;                            // 32 bits of miscellaneous flags (private)
  1019.     UInt32 features;                        // 32 bit of feature flags (public)
  1020.     UInt32 caretTime;                        // time of most recent caret drawing, in ticks
  1021.     UInt32 clickTime;                        // time of most recent click, in ticks
  1022.     SInt32 clickLoc;                        // byte offset of most recent click
  1023.     SInt32 anchorStart;                        // start offset of anchor word/line
  1024.     SInt32 anchorEnd;                        // end offset of anchor word/line
  1025.     char firstByte;                            // first byte of a double-byte character
  1026.     WEEdge clickEdge;                        // edge of character hit by most recent click
  1027.     UInt8 clickCount;                        // multiple click count
  1028.     WEAlignment alignment;                    // alignment style
  1029.     GrafPtr offscreenPort;                    // offscreen graphics world
  1030.     RgnHandle viewRgn;                        // handle to the view region
  1031.     void *refCon;                            // reference value for client use
  1032.     TSMDocumentID tsmReference;                // reference value for the text services manager
  1033.     SInt32 tsmAreaStart;                    // start of active input area (for TSM)
  1034.     SInt32 tsmAreaEnd;                        // end of active input area
  1035.     DragReference currentDrag;                // reference of drag being tracked by _WEDrag
  1036.     SInt32 dragCaretOffset;                    // offset to caret displayed during a drag
  1037.     WEActionHandle hActionStack;            // action stack for undo
  1038.     UInt32 modCount;                        // modification count
  1039.     WEClickLoopUPP clickLoop;                // click loop callback
  1040.     WEScrollUPP scrollProc;                    // scroll callback
  1041.     WETSMPreUpdateUPP tsmPreUpdate;            // TSM pre-update callback
  1042.     WETSMPostUpdateUPP tsmPostUpdate;        // TSM post-update callback
  1043.     WETranslateDragUPP translateDragHook;    // drag translation hook
  1044.     WEHiliteDropAreaUPP hiliteDropAreaHook;    // drop area highlighting hook
  1045.     WEDrawTextUPP drawTextHook;                // hook for drawing text
  1046.     WEPixelToCharUPP pixelToCharHook;        // hook for hit-testing
  1047.     WECharToPixelUPP charToPixelHook;        // hook for locating glyph position
  1048.     WELineBreakUPP lineBreakHook;            // hook for finding line breaks
  1049.     WEWordBreakUPP wordBreakHook;            // hook for finding word breaks
  1050.     WECharByteUPP charByteHook;                // hook for finding character byte type
  1051.     WECharTypeUPP charTypeHook;                // hook for finding character type
  1052.     WERunAttributes nullStyle;                // style for null selection
  1053. #if WASTE_IC_SUPPORT
  1054.     StringHandle hURLHint;                    // hint string for slack URLs
  1055. #endif
  1056. #if WASTE_OBJECTS
  1057.     WEOHTableHandle hObjectHandlerTable;    // handle to object handler table for this instance
  1058. #endif
  1059. } WERec;
  1060.  
  1061. struct SLDrawData {
  1062.     GrafPtr screenPort;
  1063.     GDHandle screenDevice;
  1064.     PixMapHandle offscreenPixels;    // offscreen pixel map
  1065.     Rect bounds;                    // bounds of offscreen buffer, in global coords
  1066.     Rect lineRect;                    // rect enclosing current line
  1067.     Rect drawRect;                    // visible portion of line rect
  1068.     Boolean usingColor;                // true if drawing in color
  1069.     Boolean usingOffscreen;            // true if an offscreen graphics world has been set up
  1070.     Boolean drawingOffscreen;        // true if actually drawing to an offscreen buffer
  1071.     Boolean doErase;                // true if line rectangle should be erased before drawing
  1072. };
  1073.  
  1074. struct SLCalcSlopData {
  1075.     SInt16 lineWidth;
  1076.     SInt16 totalSlop;
  1077.     Fixed totalProportion;
  1078. };
  1079.  
  1080. struct SLPixelToCharData {
  1081.     Fixed hPos;
  1082.     Fixed pixelWidth;
  1083.     SInt32 offset;
  1084.     WEEdge edge;
  1085. };
  1086.  
  1087. struct SLCharToPixelData {
  1088.     LongPt *thePoint;
  1089.     SInt32 offset;
  1090.     SInt16 direction;
  1091. };
  1092.  
  1093.  
  1094. #if defined(powerc) || defined (__powerc)
  1095. #pragma options align=reset
  1096. #endif
  1097.  
  1098. #ifdef __cplusplus
  1099. extern "C" {
  1100. #endif
  1101.  
  1102. // Routines in WEUtilities.c
  1103. pascal void _WEForgetHandle(Handle *h);
  1104. pascal Boolean _WESetHandleLock(Handle h, Boolean lock);
  1105. pascal void _WEBlockClr(void *block, Size blockSize);
  1106. pascal Boolean _WEBlockCmp(const void *block1, const void *block2, Size blockSize);
  1107. pascal void _WEReorder(SInt32 *a, SInt32 *b);
  1108. pascal OSErr _WEAllocate(Size blockSize, UInt32 allocFlags, Handle *h);
  1109.  
  1110. // in WEArrays.c
  1111. pascal OSErr _WEInsertBlock(Handle h, const void *blockPtr, Size blockSize, SInt32 offset);
  1112. pascal void _WERemoveBlock(Handle h, Size blockSize, SInt32 offset);
  1113.  
  1114. // in WEBirthDeath.c
  1115. extern const Point kOneToOneScaling;
  1116. pascal OSErr _WERegisterWithTSM(WEHandle hWE);
  1117. pascal void _WESetStandardHooks(WEHandle hWE);
  1118. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, UInt32 features, WEHandle *hWE);
  1119. pascal void _WEResetStyleTable(WEHandle hWE);
  1120. pascal void WEDispose(WEHandle hWE);
  1121. pascal OSErr WEUseText(Handle text, WEHandle hWE);
  1122. pascal void _WEStdDrawText(Ptr pText, SInt32 textLength, Fixed slop,
  1123.                 JustStyleCode styleRunPosition, WEHandle hWE);
  1124. pascal SInt32 _WEStdPixelToChar(Ptr pText, SInt32 textLength, Fixed slop,
  1125.                 Fixed *width, WEEdge *edge, JustStyleCode styleRunPosition,
  1126.                 Fixed hPos, WEHandle hWE);
  1127. pascal SInt16 _WEStdCharToPixel(Ptr pText, SInt32 textLength, Fixed slop,
  1128.                 SInt32 offset, SInt16 direction, JustStyleCode styleRunPosition,
  1129.                 SInt32 hPos, WEHandle hWE);
  1130. pascal StyledLineBreakCode _WEStdLineBreak(Ptr pText, SInt32 textLength,
  1131.                 SInt32 textStart, SInt32 textEnd, Fixed *textWidth,
  1132.                 SInt32 *textOffset, WEHandle hWE);
  1133. pascal void _WEStdWordBreak(Ptr pText, SInt16 textLength, SInt16 offset,
  1134.                 WEEdge edge, OffsetTable breakOffsets, ScriptCode script,
  1135.                 WEHandle hWE);
  1136. pascal SInt16 _WEStdCharByte(Ptr pText, SInt16 textLength, ScriptCode script,
  1137.                 WEHandle hWE);
  1138. pascal SInt16 _WEStdCharType(Ptr pText, SInt16 textLength, ScriptCode script,
  1139.                 WEHandle hWE);
  1140. pascal SInt16 _WEScriptToFont(ScriptCode script);
  1141. pascal void _WEOldWordBreak(Ptr pText, SInt16 textLength, SInt16 offset,
  1142.                 WEEdge edge, OffsetTable breakOffsets, ScriptCode script,
  1143.                 WEHandle hWE);
  1144. pascal SInt16 _WEOldCharByte(Ptr pText, SInt16 textLength, ScriptCode script,
  1145.                 WEHandle hWE);
  1146. pascal SInt16 _WEOldCharType(Ptr pText, SInt16 textLength, ScriptCode script,
  1147.                 WEHandle hWE);
  1148. pascal Boolean _WEStdClickLoop(WEHandle hWE);
  1149. pascal OSErr _WEStdHiliteDropArea(DragReference drag, Boolean hiliteFlag, WEHandle hWE);
  1150.  
  1151. // in WEDebug.c
  1152. pascal void _WESanityCheck(WEHandle hWE);
  1153.  
  1154. // in WEInlineInput.c
  1155. pascal OSErr _WEHiliteRangeArray(TextRangeArrayHandle hTray, WEHandle hWE);
  1156. pascal OSErr _WEHandleUpdateActiveInputArea(const AppleEvent *ae, AppleEvent *reply, SInt32 handlerRefCon);
  1157. pascal OSErr _WEHandlePositionToOffset(const AppleEvent *ae, AppleEvent *reply, SInt32 handlerRefCon);
  1158. pascal OSErr _WEHandleOffsetToPosition(const AppleEvent *ae, AppleEvent *reply, SInt32 handlerRefCon);
  1159. pascal OSErr WEInstallTSMHandlers(void);
  1160. pascal OSErr WERemoveTSMHandlers(void);
  1161.  
  1162. // in WELongCoords.c
  1163. pascal SInt32 _WEPinInRange(SInt32 value, SInt32 rangeStart, SInt32 rangeEnd);
  1164. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  1165. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  1166. pascal void WESetLongRect(LongRect *lr, SInt32 left, SInt32 top, SInt32 right, SInt32 bottom);
  1167. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  1168. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  1169. pascal void WEOffsetLongRect(LongRect *lr, SInt32 hOffset, SInt32 vOffset);
  1170. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  1171.  
  1172. // in WEDrawing.c
  1173. pascal SInt32 WEOffsetToLine (SInt32 offset, WEHandle hWE);
  1174. pascal SInt32 _WEPixelToLine(SInt32 vOffset, WEHandle hWE);
  1175. pascal SInt32 _WEOffsetToRun (SInt32 offset, WEHandle hWE);
  1176. pascal void _WEGetIndStyle(SInt32 runIndex, WERunInfo *info, WEHandle hWE);
  1177. pascal void WEGetRunInfo(SInt32 offset, WERunInfo *info, WEHandle hWE);
  1178. pascal OSErr WEGetSelectedObject(WEObjectDescHandle *hObjectDesc, WEHandle hWE);
  1179. pascal SInt32 WEFindNextObject(SInt32 offset, WEObjectDescHandle *hObjectDesc, WEHandle hWE);
  1180. pascal void _WEContinuousStyleRange(SInt32 rangeStart, SInt32 rangeEnd,
  1181.         WEStyleMode *mode, WETextStyle *ts, WEHandle hWE);
  1182. pascal void _WESynchNullStyle(WEHandle hWE);
  1183. pascal Boolean WEContinuousStyle(WEStyleMode *mode, TextStyle *ts, WEHandle hWE);
  1184. pascal void _WESegmentLoop(SInt32 firstLine, SInt32 lastLine, SegmentLoopProcPtr callback, void *callbackData, WEHandle hWE);
  1185. pascal void _WEDrawTSMHilite(Rect *segmentRect, UInt8 tsFlags);
  1186. pascal void _WEDrawLines (SInt32 firstLine, SInt32 lastLine, Boolean doErase, WEHandle hWE);
  1187. pascal SInt16 _WECalcPenIndent(SInt16 slop, WEAlignment alignment);
  1188. pascal void _WESaveQDEnvironment(GrafPtr port, Boolean saveColor, QDEnvironment *environment);
  1189. pascal void _WERestoreQDEnvironment(const QDEnvironment *environment);
  1190. pascal void _WEFillFontInfo (GrafPtr port, WERunAttributes *targetStyle);
  1191. pascal void _WECopyStyle (const WETextStyle *sourceStyle, WETextStyle *targetStyle,
  1192.         Style offStyles, WEStyleMode mode);
  1193. pascal Boolean _WEOffsetInRange(SInt32 offset, WEEdge edge, SInt32 rangeStart, SInt32 rangeEnd);
  1194.  
  1195. // WELineLayout.c
  1196. pascal void WEStopInlineSession(WEHandle hWE);
  1197. pascal void _WERemoveLine(SInt32 lineIndex, WEPtr pWE);
  1198. pascal OSErr _WEInsertLine(SInt32 lineIndex, const LineRec *pLine, WEPtr pWE);
  1199. pascal void _WEBumpOrigin(SInt32 lineIndex, SInt32 deltaOrigin, WEPtr pWE);
  1200. pascal SInt32 _WEFindLineBreak(SInt32 lineStart, WEHandle hWE);
  1201. pascal void _WECalcHeights(SInt32 rangeStart, SInt32 rangeEnd, SInt16 *lineAscent, SInt16 *lineDescent,
  1202.         WEHandle hWE);
  1203. pascal OSErr _WERecalBreaks(SInt32 *startLine, SInt32 *endLine, WEHandle hWE);
  1204. pascal void _WERecalSlops(SInt32 firstLine, SInt32 lastLine, WEHandle hWE);
  1205. pascal OSErr WECalText(WEHandle hWE);
  1206. pascal WEAlignment WEGetAlignment(WEHandle hWE);
  1207. pascal void WEGetSelection(SInt32 *selStart, SInt32 *selEnd, WEHandle hWE);
  1208. pascal void WESetDestRect(const LongRect *destRect, WEHandle hWE);
  1209. pascal void WEGetDestRect(LongRect *destRect, WEHandle hWE);
  1210. pascal void WESetViewRect(const LongRect *viewRect, WEHandle hWE);
  1211. pascal void WEGetViewRect(LongRect *viewRect, WEHandle hWE);
  1212. pascal SInt32 WEGetTextLength(WEHandle hWE);
  1213. pascal SInt32 WECountLines(WEHandle hWE);
  1214. pascal SInt32 WEGetHeight(SInt32 startLine, SInt32 endLine, WEHandle hWE);
  1215. pascal void WEGetLineRange(SInt32 lineNo, SInt32 *lineStart, SInt32 *lineEnd, WEHandle hWE);
  1216. pascal Handle WEGetText(WEHandle hWE);
  1217. pascal SInt16 WEGetChar(SInt32 offset, WEHandle hWE);
  1218. pascal SInt16 WEFeatureFlag(SInt16 feature, SInt16 action, WEHandle hWE);
  1219.  
  1220. // WESelecting.c
  1221. pascal void _WEClearHiliteBit(void);
  1222. pascal SInt32 WEGetOffset(const LongPt *thePoint, WEEdge *edge, WEHandle hWE);
  1223. pascal void WEGetPoint(SInt32 offset, SInt16 direction, LongPt *thePoint, SInt16 *lineHeight, WEHandle hWE);
  1224. pascal void WEFindLine(SInt32 offset, WEEdge edge, SInt32 *lineStart, SInt32 *lineEnd, WEHandle hWE);
  1225. pascal SInt16 _WEGetContext(SInt32 offset, SInt32 *contextStart, SInt32 *contextEnd,
  1226.                         WEHandle hWE);
  1227. pascal SInt16 _WEGetRestrictedContext(SInt32 offset, SInt32 *contextStart, SInt32 *contextEnd,
  1228.                         WEHandle hWE);
  1229. pascal void WEFindWord(SInt32 offset, WEEdge edge, SInt32 *wordStart, SInt32 *wordEnd, WEHandle hWE);
  1230. pascal SInt16 WECharByte(SInt32 offset, WEHandle hWE);
  1231. pascal SInt16 WECharType(SInt32 offset, WEHandle hWE);
  1232. pascal void _WEDrawCaret(SInt32 offset, WEHandle hWE);
  1233. pascal void _WEBlinkCaret(WEHandle hWE);
  1234. pascal RgnHandle WEGetHiliteRgn(SInt32 rangeStart, SInt32 rangeEnd, WEHandle hWE);
  1235. pascal void _WEHiliteRange(SInt32 rangeStart, SInt32 rangeEnd, WEHandle hWE);
  1236. pascal void WESetSelection(SInt32 selStart, SInt32 selEnd, WEHandle hWE);
  1237. pascal void WESetAlignment(WEAlignment alignment, WEHandle hWE);
  1238. pascal SInt32 _WEArrowOffset(SInt16 action, SInt32 offset, WEHandle hWE);
  1239. pascal void _WEDoArrowKey (SInt16 arrow, EventModifiers modifiers, WEHandle hWE);
  1240. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEHandle hWE);
  1241. pascal void WEIdle(UInt32 *maxSleep, WEHandle hWE);
  1242. pascal void WEUpdate(RgnHandle updateRgn, WEHandle hWE);
  1243. pascal void WEDeactivate(WEHandle hWE);
  1244. pascal void WEActivate(WEHandle hWE);
  1245. pascal Boolean WEIsActive(WEHandle hWE);
  1246. pascal void WEScroll(SInt32 hOffset, SInt32 vOffset, WEHandle hWE);
  1247. pascal void WEPinScroll(SInt32 hOffset, SInt32 vOffset, WEHandle hWE);
  1248. pascal Boolean _WEScrollIntoView (SInt32 offset, WEHandle hWE);
  1249. pascal void WESelView(WEHandle hWE);
  1250.  
  1251. // WELowLevelEditing.c
  1252. pascal Boolean _WEIsWordRange(SInt32 rangeStart, SInt32 rangeEnd, WEHandle hWE);
  1253. pascal Boolean _WEIsPunct(SInt32 offset, WEHandle hWE);
  1254. pascal void _WEIntelligentCut(SInt32 *rangeStart, SInt32 *rangeEnd, WEHandle hWE);
  1255. pascal SInt16 _WEIntelligentPaste(SInt32 rangeStart, SInt32 rangeEnd, WEHandle hWE);
  1256. pascal OSErr _WEInsertRun(SInt32 runIndex, SInt32 offset, SInt32 styleIndex, WEPtr pWE);
  1257. pascal void _WERemoveRun(SInt32 runIndex, WEPtr pWE);
  1258. pascal void _WEChangeRun(SInt32 runIndex, SInt32 newStyleIndex, Boolean keepOld, WEPtr pWE);
  1259. pascal OSErr _WENewStyle(const WETextStyle *ts, SInt32 *styleIndex, WEPtr pWE);
  1260. pascal OSErr _WERedraw(SInt32 rangeStart, SInt32 rangeEnd, WEHandle hWE);
  1261. pascal OSErr _WESetStyleRange(SInt32 rangeStart, SInt32 rangeEnd, WEStyleMode mode,
  1262.                 const WETextStyle *ts, WEHandle hWE);
  1263. pascal OSErr _WEApplyStyleScrap(SInt32 rangeStart, SInt32 rangeEnd, StScrpHandle styleScrap, WEHandle hWE);
  1264. pascal OSErr _WEApplySoup(SInt32 offset, Handle hSoup, WEHandle hWE);
  1265. pascal void _WEBumpRunStart(SInt32 runIndex, SInt32 deltaRunStart, WEPtr pWE);
  1266. pascal void _WERemoveRunRange(SInt32 rangeStart, SInt32 rangeEnd, WEHandle hWE);
  1267. pascal void _WEBumpLineStart(SInt32 lineIndex, SInt32 deltaLineStart, WEPtr pWE);
  1268. pascal void _WERemoveLineRange(SInt32 rangeStart, SInt32 rangeEnd, WEHandle hWE);
  1269. pascal OSErr _WEDeleteRange(SInt32 rangeStart, SInt32 rangeEnd, WEHandle hWE);
  1270. pascal OSErr _WEInsertText(SInt32 offset, Ptr textPtr, SInt32 textLength, WEHandle hWE);
  1271.  
  1272. // WEHighLevelEditing.c
  1273. pascal void _WEPushAction(WEActionHandle hAction);
  1274. pascal OSErr _WENewAction(SInt32 rangeStart, SInt32 rangeEnd, SInt32 newTextLength,
  1275.                             WEActionKind actionKind, WEActionFlags actionFlags,
  1276.                             WEHandle hWE, WEActionHandle *hAction);
  1277. pascal void _WEDisposeAction(WEActionHandle hAction);
  1278. pascal void _WEForgetAction(WEActionHandle *hAction);
  1279. pascal OSErr _WEDoAction(WEActionHandle hAction);
  1280. pascal OSErr WEUndo(WEHandle hWE);
  1281. pascal void WEClearUndo(WEHandle hWE);
  1282. pascal WEActionKind WEGetUndoInfo(Boolean *redoFlag, WEHandle hWE);
  1283. pascal UInt32 WEGetModCount(WEHandle hWE);
  1284. pascal void WEResetModCount(WEHandle hWE);
  1285. pascal void _WEAdjustUndoRange(SInt32 moreBytes, WEHandle hWE);
  1286. pascal OSErr _WETypeChar(char theByte, WEHandle hWE);
  1287. pascal OSErr _WEBackspace(WEHandle hWE);
  1288. pascal OSErr _WEForwardDelete(WEHandle hWE);
  1289. pascal Boolean WEIsTyping(WEHandle hWE);
  1290. pascal void WEKey(SInt16 key, EventModifiers modifiers, WEHandle hWE);
  1291. pascal OSErr WEInsert(Ptr textPtr, SInt32 textLength, StScrpHandle hStyles, Handle hSoup, WEHandle hWE);
  1292. pascal OSErr WEInsertObject(FlavorType objectType, Handle objectDataHandle, Point objectSize, WEHandle hWE);
  1293. pascal OSErr WEDelete(WEHandle hWE);
  1294. pascal OSErr WECut(WEHandle hWE);
  1295. pascal Boolean WECanPaste(WEHandle hWE);
  1296. pascal OSErr WEPaste(WEHandle hWE);
  1297. pascal OSErr _WESmartSetFont(WEStyleMode mode, const TextStyle *ts, WEHandle hWE);
  1298. pascal OSErr WESetStyle(WEStyleMode mode, const TextStyle *ts, WEHandle hWE);
  1299. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEHandle hWE);
  1300. pascal OSErr WEUseSoup(Handle hSoup, WEHandle hWE);
  1301.  
  1302. // WEMouse.c
  1303. pascal Boolean _WEIsOptionDrag(DragReference drag);
  1304. pascal OSErr _WEGetFlavor(DragReference drag, ItemReference dragItem,
  1305.                 FlavorType requestedType, Handle hFlavor,
  1306.                 SInt32 dropOffset, WEHandle hWE);
  1307. pascal OSErr _WEExtractFlavor(DragReference drag, ItemReference dragItem,
  1308.                         FlavorType theType, Handle *hFlavor,
  1309.                         SInt32 dropOffset, WEHandle hWE);
  1310. pascal Boolean WECanAcceptDrag(DragReference drag, WEHandle hWE);
  1311. pascal void _WEUpdateDragCaret(SInt32 offset, WEHandle hWE);
  1312. pascal OSErr WETrackDrag(DragTrackingMessage message, DragReference drag,
  1313.                                     WEHandle hWE);
  1314. pascal OSErr WEReceiveDrag(DragReference drag, WEHandle hWE);
  1315. pascal OSErr _WESendFlavor(FlavorType requestedType, void *dragSendRefCon,
  1316.                                     WEHandle hWE, DragReference drag);
  1317. pascal Boolean WEDraggedToTrash(DragReference drag);
  1318. pascal OSErr _WEDrag(Point mouseLoc, EventModifiers modifiers, UInt32 clickTime, WEHandle hWE);
  1319. pascal void _WEResolveURL(EventModifiers modifiers, SInt32 urlStart, SInt32 urlEnd, WEHandle hWE);
  1320. pascal void WEClick(Point mouseLoc, EventModifiers modifiers, UInt32 clickTime, WEHandle hWE);
  1321. pascal UInt16 WEGetClickCount(WEHandle hWE);
  1322.  
  1323. // WEObjects.c
  1324. pascal FlavorType WEGetObjectType(WEObjectDescHandle hObjectDesc);
  1325. pascal Handle WEGetObjectDataHandle(WEObjectDescHandle hObjectDesc);
  1326. pascal Point WEGetObjectSize(WEObjectDescHandle hObjectDesc);
  1327. pascal WEHandle WEGetObjectOwner(WEObjectDescHandle hObjectDesc);
  1328. pascal SInt32 WEGetObjectRefCon(WEObjectDescHandle hObjectDesc);
  1329. pascal void WESetObjectRefCon(WEObjectDescHandle hObjectDesc, SInt32 refCon);
  1330. pascal SInt32 _WELookupObjectType(FlavorType objectType, WEOHTableHandle hTable);
  1331. pascal OSErr _WEGetIndObjectType(SInt32 index, FlavorType *objectType, WEHandle hWE);
  1332. pascal OSErr _WENewObject(FlavorType objectType, Handle objectDataHandle, WEHandle hWE,
  1333.                     WEObjectDescHandle *hObjectDesc);
  1334. pascal OSErr _WEFreeObject(WEObjectDescHandle hObjectDesc);
  1335. pascal OSErr _WEDrawObject(WEObjectDescHandle hObjectDesc);
  1336. pascal Boolean _WEClickObject(Point hitPt, EventModifiers modifiers, UInt32 clickTime,
  1337.                                 WEObjectDescHandle hObjectDesc);
  1338. pascal OSErr _WEStreamObject(SInt16 destKind, FlavorType *theType, Handle *theData,
  1339.                 Boolean *canDisposeData, WEObjectDescHandle hObjectDesc);
  1340. pascal OSErr WEInstallObjectHandler(FlavorType objectType, WESelector handlerSelector,
  1341.                 UniversalProcPtr handler, WEHandle hWE);
  1342. pascal OSErr WEGetObjectHandler(FlavorType objectType, WESelector handlerSelector,
  1343.                 UniversalProcPtr *handler, WEHandle hWE);
  1344.  
  1345. // WEScraps.c
  1346. pascal OSErr _WEPrependStyle(Handle hStyleScrap, const WERunInfo *info, SInt32 offsetDelta);
  1347. pascal OSErr _WEAppendStyle(Handle hStyleScrap, const WERunInfo *info, SInt32 offset);
  1348. pascal OSErr _WEPrependObject(Handle hSoup, const WERunInfo *info, SInt32 offsetDelta);
  1349. pascal OSErr _WEAppendObject(Handle hSoup, const WERunInfo *info, SInt32 offset);
  1350. pascal OSErr WECopyRange(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, Handle
  1351.                     hStyles, Handle hSoup, WEHandle hWE);
  1352. pascal OSErr WECopy(WEHandle hWE);
  1353.  
  1354. // WESharedLibrary.c
  1355. pascal OSErr _WECFMInitialize(const CFragInitBlock *theInitBlock);
  1356. pascal void _WECFMTerminate(void);
  1357. pascal UInt32 WEVersion(void);
  1358.  
  1359. // WESelectors.c
  1360. extern WELookupTable _weMainSelectorTable[];
  1361. extern WELookupTable _weObjectHandlerSelectorTable[];
  1362. pascal void _WELookupSelector(const WELookupTable *table, WESelector selector, WEFieldDescriptor *desc);
  1363. pascal OSErr _WEGetField(const WELookupTable *table, WESelector selector, SInt32 *info, void *structure);
  1364. pascal OSErr _WESetField(const WELookupTable *table, WESelector selector, SInt32 *info, void *structure);
  1365. pascal OSErr WEGetInfo(WESelector selector, void *info, WEHandle hWE);
  1366. pascal OSErr WESetInfo(WESelector selector, const void *info, WEHandle hWE);
  1367.  
  1368. #ifdef __cplusplus
  1369. }
  1370. #endif
  1371.